<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <script src="js/axios.js"></script>
  <script>
    function get1() {
      axios.get('http://localhost/axios/p/get?id=123&&username=abc').then(function (ret) {
        document.getElementById('msg').innerHTML=ret.data;
      });
    }
    function get2() {
      axios.get('http://localhost/axios/p/get',{params:{id:456,username:'abc'}}).then(ret=> {
        document.getElementById('msg').innerHTML=ret.data;;
      });
    }
    function post() {
      var p=new URLSearchParams();
      p.append('id','234');
      p.append('name','hello');
      axios.post('http://localhost/axios/p/post', p).then(ret=> {
        document.getElementById('msg').innerHTML=ret.data;
      })
    }
  </script>
</head>
<body>
<!--1.普通请求-->
<form action="http://localhost/axios/p" method="post">
  <input placeholder="输入id值" name="id">
  <input type="submit">
</form>
<!--2.异步请求-->
<button onclick="get1();">get1请求,url传参</button><br>
<button onclick="get2();">get2请求,表单传参</button><br>
<button onclick="post();">post请求,表单传参</button><br>
<span id="msg" style="color:red;"></span>
</body>
</html>